<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>团单激活</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp"%>
<link rel="stylesheet" href="css/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" href="css/jquery.datetimepicker.css" type="text/css" />
<link rel="stylesheet" href="css/poshytip/tip-yellowsimple/tip-yellowsimple.css" type="text/css" />
<script type="text/javascript" src="js/jquery.datetimepicker.js"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script type="text/javascript" src="js/poshytip/jquery.poshytip.js"></script>
<script type="text/javascript" src="js/checkPppUnit.js"></script>
<script type="text/javascript" src="js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="js/jquery.ztree.excheck-3.5.js"></script>
<style type="text/css">
.scroll_body {
    height: 350px;
    overflow: scroll;
    overflow-x: hidden;
    padding: 20px 100px 0;
    margin-bottom: 20px;
}
.setp {
	margin-bottom: 20px
}

.input_text {
	width: 250px;
}

.td_label {
	text-align: right;
	padding-right: 10px;
}
</style>
<script type="text/javascript">
	var MAX_DAYS, MIN_DAYS, UNIR_PP, MAX_DELAY_DAY, MIN_DELAY_DAY, INSTANT, PPP_UNIT, DMY_DESC;
	var global_SPECIAL_INFO = '';
	var facadeAppInsureds = new Array();
	var idStr;
	var riskMainType='';
	$(function() {
        $.openLoading_jhk();
	    var stagNo=$("#stagNo").val();
		if(stagNo!=null&&stagNo!=''){
	        loadAppFormAndInsured();
		}
		$.closeLoading();
		$('input,select').poshytip({
			className : 'tip-yellowsimple',
			showOn : 'none',
			alignTo : 'target',
			alignX : 'right',
			offsetX : 20,
			offsetY : -26,
			showTimeout : 100
		});
		// lfd changed 激活卡弹窗将tip添加到弹窗内 20180919 ---- start
		$('#editInsuredDiv input').poshytip({
            className : 'tip-yellowsimple',
            showOn : 'none',
            alignTo : 'target',
            alignX : 'right',
            offsetX : 20,
            offsetY : -26,
            showTimeout : 100,
            setEle: '#editInsuredDiv' // 被插入到的标签
        });
		$('#editInsuredDiv select').poshytip({
            className : 'tip-yellowsimple',
            showOn : 'none',
            alignTo : 'target',
            alignX : 'right',
            offsetX : 20,
            offsetY : -26,
            showTimeout : 100,
            setEle: '#editInsuredDiv' // 被插入到的标签
        });
		// lfd changed 激活卡弹窗将tip添加到弹窗内 20180919 ---- end
		$('.notNullClass').bind('change', function() {
			if ($(this).val() != '') {
				$(this).css('border', '1px solid #c3c3c3');
				$(this).poshytip('hide');
	            if($(this).attr('id')=='chassisNum'){
	                $('#plateNum').css('border','1px solid #c3c3c3');
	                $('#plateNum').poshytip('hide');
	            }
			}
		});
		var pricelessType = '${prodInfo.cardInfo.pricelessType}';
		//进度条处理
		if (pricelessType == '1') {
			stepConObj.curStepIndex = 1;//当前已完成索引位置
			stepConObj.stepContentFlag = "2";//1非见费和2见费标识
			stepControl(stepConObj);
		} else {
			stepConObj.curStepIndex = 1;//当前已完成索引位置
			stepConObj.stepContentFlag = "1";//1非见费和2见费标识
			stepControl(stepConObj);
		}
		initValidateData();
		//驾乘险时不显示被保人信息
	    if(riskMainType!='2'){
	        $(".appInsuredClass").show();
	    }else{
	        $(".appInsuredClass").hide();
	        $("#commonInsure").hide();
	    }
		//出生日期初始化
	    $('#clientBir1,#clientBir2').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d',maxDate:'0',onChangeDateTime:changeDate,scrollMonth:false,scrollTime:false,scrollInput:false});
	    
		//点击即时起保引起时间显示
		$(".realSignFlag").bind(
				'click',
				function() {
					if ($(this).val() == 'Y') {
						$('#effDate').datetimepicker({
							lang : 'ch',
							validateOnBlur : false,
							timepicker : true,
							format : 'Y-m-d H:00:00',
							minDate : '0',
							onChangeDateTime : changeTermDate,
							scrollMonth : false,
							scrollTime : false
						});
						$('#effDate').val(getDefaultDate(new Date(), 0, 1));
					} else {
						$('#effDate').datetimepicker({
							lang : 'ch',
							validateOnBlur : false,
							timepicker : false,
							format : 'Y-m-d H:00:00',
							minDate : MIN_DELAY_DAY,
							onChangeDateTime : changeTermDate,
							scrollMonth : false,
							scrollTime : false
						});
						$('#effDate').val(getDefaultDate(new Date(), 0, 1+Number(MIN_DELAY_DAY)));
					}

					var dayCount = $("#dayCount").val();
					var effDate = $('#effDate').val();
					var date = new Date(effDate.replace(/-/g, "/"));
					effDate = effDate + "";
					if (PPP_UNIT == 'y') {
						date.calTermDateByMonthOrYear(effDate, 'Y', dayCount,
								$(this).val());
					} else if (PPP_UNIT == 'm') {
						date.calTermDateByMonthOrYear(effDate, 'M', dayCount,
								$(this).val());
					} else {
						$("#termDate").val(
								getDefaultDate(new Date(),
										$("#dayCount").val(), 1));
					}
				});

		//天数改变引起终保日期改变
		$("#dayCount").bind('change',function() {
			var dayCount = $(this).val();
			if (dayCount == '') {
				$(this).css('border', '1px solid red');
				$(this).poshytip('update', '请填写' + DMY_DESC);
				$(this).poshytip('show');
				return;
			}
			if (isNaN(dayCount)) {
				$(this).css('border', '1px solid red');
				$(this).poshytip('update', DMY_DESC + '应为整数');
				$(this).poshytip('show');
				return;
			}
			if (dayCount-MIN_DAYS<0) {
				$(this).css('border', '1px solid red');
				$(this).poshytip('update',
						DMY_DESC + "最小为" + MIN_DAYS);
				$(this).poshytip('show');
				return;
			}
			var MAXDAY = MAX_DAYS;
			if (MAX_DAYS == 365)
				MAXDAY = 366;
			if (dayCount-MAXDAY>0) {
				$(this).css('border', '1px solid red');
				$(this).poshytip('update',
						DMY_DESC + "最大为" + MAX_DAYS);
				$(this).poshytip('show');
				return;
			}

			var effDate = $("#effDate").val();
			var dateCur = new Date(effDate.replace(/-/g, "/"));
			if (dayCount == 366 && !isRunYear(dateCur)) {
				$(this).css('border', '1px solid red');
				$(this).poshytip('update', "平年保险天数最大为365天");
				$(this).poshytip('show');
				return;
			}

			$(this).css('border', '1px solid #c3c3c3');
			$(this).poshytip('hide');
			var effDate = $("#effDate").val();
			if (dayCount != '' && effDate.length == 19) {
				var realSignFlag = $(
						"input[name='realSignFlag']:checked")
						.val();
				var date = new Date(effDate.replace(/-/g, "/"));
				effDate = effDate + "";
				if (PPP_UNIT == 'y') {
					date.calTermDateByMonthOrYear(effDate, 'Y',
							dayCount, realSignFlag);
				} else if (PPP_UNIT == 'm') {
					date.calTermDateByMonthOrYear(effDate, 'M',
							dayCount, realSignFlag);
				} else {
					$("#termDate").val(
							getDefaultDate(date, dayCount, 0));
				}
			}
		});
		changeTbrIdType();
		//投保人身份证
		$("#certificateCode").bind('change',function() {
			var cc = $(this).val();
			if ($("#certificateType").val() == '01') {
				if (identityCodeValid(cc, 'certificateCode')) {
					$('#certificateCode').css('border',
							'1px solid #c3c3c3');
					$('#certificateCode').poshytip('hide');
					if (cc.length == 15) {
						$("#clientBir1").val(
								"19" + cc.substr(6, 2) + "-"
										+ cc.substr(8, 2) + "-"
										+ cc.substr(10, 2));
						if (parseInt(cc.substr(13, 1)) % 2 == 1) {
							$("#sexId1").prop('checked', true);
						} else {
							$("#sexId2").prop('checked', true);
						}
					}
					if (cc.length == 18) {
						$("#clientBir1").val(
								cc.substr(6, 4) + "-"
										+ cc.substr(10, 2)
										+ "-"
										+ cc.substr(12, 2));
						if (parseInt(cc.substr(16, 1)) % 2 == 1) {
							$("#sexId1").prop('checked', true);
						} else {
							$("#sexId2").prop('checked', true);
						}
					}
					$("#clientBir1").css('border',
							'1px solid #c3c3c3');
					$("#clientBir1").poshytip('hide');
					$("#sexId2").poshytip('hide');
				}
			} else if ($("#certificateType").val() == '05'
					&& cc.length == 18) {
				$('#certificateCode').css('border',
						'1px solid #c3c3c3');
				$('#certificateCode').poshytip('hide');
				if (identityCodeValidToBack(cc)) {
					$("#clientBir1").val(
							cc.substr(6, 4) + "-"
									+ cc.substr(10, 2) + "-"
									+ cc.substr(12, 2));
					if (parseInt(cc.substr(16, 1)) % 2 == 1) {
						$("#sexId1").prop('checked', true);
					} else {
						$("#sexId2").prop('checked', true);
					}
				}
			} else {
				$('#certificateCode').css('border',
						'1px solid #c3c3c3');
				$('#certificateCode').poshytip('hide');
			}
		});

// 		//行程/航班事件
// 		$("#trip").bind('change', function() {
// 			var trip = $(this).val();
// 			if (trip == '') {
// 				$(this).css('border', '1px solid red');
// 				$(this).poshytip('update', '请填写行程/航班');
// 				$(this).poshytip('show');
// 				return;
// 			} else {
// 				$(this).css('border', '1px solid #c3c3c3');
// 				$(this).poshytip('hide');
// 			}
// 		});
        //与被保险人关系
        $("#relWithInsured1").bind('change',function() {
            var relWithInsured = $(this).val();
            if (relWithInsured!='01') {
                $(this).css('border', '1px solid #c3c3c3');
                $(this).poshytip('hide');
            } else {
                $(this).css('border', '1px solid red');
                $(this).poshytip('update', '投保人与被保人关系不可以选本人');
                $(this).poshytip('show');
            }
        });
		//电子邮箱校验
		$("#email").bind('change',function() {
			var email = $(this).val();
			if (email != '') {
				var emailReg1 = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/g;
				if (emailReg1.test(email)) {
					$(this).css('border', '1px solid #c3c3c3');
					$(this).poshytip('hide');
				} else {
					$(this).css('border', '1px solid red');
					$(this).poshytip('update', '电子邮箱格式错误');
					$(this).poshytip('show');
				}
			} else {
				$(this).css('border', '1px solid #c3c3c3');
				$(this).poshytip('hide');
			}
		});
		//投保人证件类型
		$('#certificateType').change(function() {
			//$('#certificateCode').val('');
			if ($(this).val() != "01") {
				$('#certificateCode').css('border', '1px solid #c3c3c3');
				$('#certificateCode').poshytip('hide');
			}
		});
// 		$("#anesthType").bind('change', function() {
// 			if (global_SPECIAL_INFO == '1') {
// 				if ($(this).val() == "") {
// 					$('#anesthType').css('border', '1px solid red');
// 					$('#anesthType').poshytip('update', '请选择麻醉类型');
// 					$('#anesthType').poshytip('show');
// 				} else {
// 					$("#anesthType").css('border', '1px solid #c3c3c3');
// 					$("#anesthType").poshytip('hide');
// 				}
// 			}
// 		});
		//被保人证件类型
	    $('#idType').change(function(){
	        if($(this).val()!="01"){
	            $("#idNo").css('border','1px solid #c3c3c3');
	            $("#idNo").poshytip('hide');
	        }
	    });
	    //被保人身份证
	    $("#idNo").change(function(){
	        var cc = $(this).val();
	        if($("#idType").val()=='01'){
	            if(identityCodeValid(cc,'idNo')){
	                $('#idNo').css('border','1px solid #c3c3c3');
	                $('#idNo').poshytip('hide');
	                if(cc.length==15){
	                    $("#clientBir2").val("19"+cc.substr(6,2)+"-"+cc.substr(8,2)+"-"+cc.substr(10,2));
	                    if (parseInt(cc.substr(13, 1)) % 2 == 1) {
	                        $("#sexId3").prop('checked',true);
	                    } else {
	                        $("#sexId4").prop('checked',true);
	                    } 
	                }
	                if(cc.length==18){
	                    $("#clientBir2").val(cc.substr(6,4)+"-"+cc.substr(10,2)+"-"+cc.substr(12,2));
	                    if (parseInt(cc.substr(16, 1)) % 2 == 1) {
	                        $("#sexId3").prop('checked',true);
	                    } else {
	                        $("#sexId4").prop('checked',true);
	                    } 
	                }
	                $('#clientBir2,#sexId4').css('border','1px solid #c3c3c3');
	                $('#clientBir2,#sexId4').poshytip('hide');
	            }
	        }else if($("#idType").val()=='05'&&cc.length==18){
	            $('#idNo').css('border','1px solid #c3c3c3');
	            $('#idNo').poshytip('hide');
	            if(identityCodeValidToBack(cc)){
	                $("#clientBir2").val(cc.substr(6,4)+"-"+cc.substr(10,2)+"-"+cc.substr(12,2));
	                if (parseInt(cc.substr(16, 1)) % 2 == 1) {
	                    $("#sexId3").prop('checked',true);
	                } else {
	                    $("#sexId4").prop('checked',true);
	                } 
	                $('#clientBir2,#sexId4').css('border','1px solid #c3c3c3');
	                $('#clientBir2,#sexId4').poshytip('hide');
	            }
	        }else{
	            $('#idNo').css('border','1px solid #c3c3c3');
	            $('#idNo').poshytip('hide');
	        }
	    });
	});
	function changeTbrIdType(){
		var idType=$("#appNature").val();
		var s = document.getElementById("certificateType").options;
		s.length=0;
		if(idType=="1"){
			var id=${id01};
			for(var i in id){
			   	s.add(new Option(id[i].codeName,id[i].code));
			}
		}else if(idType=="5"){
			var id=${id03};
			for(var i in id){
				s.add(new Option(id[i].codeName,id[i].code));
			}
		}else{
			var id=${id02};
			for(var i in id){
				s.add(new Option(id[i].codeName,id[i].code));
			}
		}
	}
	function initValidateData() {
		//根据投保方案初始化最大天数,最小天数,最大份数,最大延长天数
// 		$("#trip").css('border', '1px solid #c3c3c3');
// 		$("#trip").poshytip('hide');
        $('#plateNum').css('border','1px solid #c3c3c3');
        $('#plateNum').poshytip('hide');
        $('#seatNum').css('border','1px solid #c3c3c3');
        $('#seatNum').poshytip('hide');
        // $('#useNature').css('border','1px solid #c3c3c3');
        // $('#useNature').poshytip('hide');
        $('#mainVehicleNature').css('border','1px solid #c3c3c3');
        $('#mainVehicleNature').poshytip('hide');
		MAX_DAYS = $('#MAX_DAYS').val();
		//MAX_DAYS = $('#MAX_DAYS').val();
		MIN_DAYS = $('#MIN_DAYS').val();
		UNIR_PP = $('#UNIR_PP').val();
		MAX_DELAY_DAY = $('#MAX_DELAY_DAY').val();
		MIN_DELAY_DAY = $('#MIN_DELAY_DAY').val();
		INSTANT = $('#INSTANT').val();
		PPP_UNIT = $('#PPP_UNIT').val();
		global_SPECIAL_INFO = $('#global_SPECIAL_INFO').val();
	    riskMainType=$('#riskMainType').val();
		if (PPP_UNIT == 'y') {
			DMY_DESC = '保险年数：';
		} else if (PPP_UNIT == 'm') {
			DMY_DESC = '保险月数：';
		} else {
			DMY_DESC = '保险天数：';
		}
		//驾乘险
	    if(riskMainType == '2'){
	        $("[name='drivingInfo']").show();
	        $("[name='redInfo']").hide();
	        $("#drivingShow").show();
	    }else{
	        $("[name='redInfo']").show();
	        $("[name='drivingInfo']").hide();
	    }
		//默认处理
		defaultInterface();
	}
    function clearDepartureTime(){
        if($("#departureTime").val()!=''){
            $("#departureTime").css('border','1px solid #c3c3c3');
            $("#departureTime").poshytip('hide'); 
        }
    }
    function clearArrivalTime(){
        if($("#arrivalTime").val()!=''){
            $("#arrivalTime").css('border','1px solid #c3c3c3');
            $("#arrivalTime").poshytip('hide'); 
        }
    }
	function defaultInterface() {
        if (MAX_DAYS == MIN_DAYS) {
            $("#dayCount").attr("readonly", true);
        }
		if ("${editFlag}" != 'edit') {
			if (PPP_UNIT == 'y') {
				$("#dayCount").val(MAX_DAYS);
			}
			if (PPP_UNIT == 'm') {
				$("#dayCount").val(MAX_DAYS);
			} else {
				if (MAX_DAYS == 366) {
					$("#dayCount").val(365);
				} else {
					$("#dayCount").val(MAX_DAYS);
				}
			}

			if (INSTANT == 'Y') {
				$(".select1").attr('checked', true);
				$('#effDate').datetimepicker({
					lang : 'ch',
					validateOnBlur : false,
					timepicker : true,
					format : 'Y-m-d H:00:00',
					minDate : '0',
					onChangeDateTime : changeTermDate,
					scrollMonth : false,
					scrollTime : false
				});
				$("#effDate").unbind('mousewheel');
				$('#effDate').val(getDefaultDate(new Date(), 0, 1));
			} else {
				$(".select2").attr('checked', true);
				$('#effDate').datetimepicker({
					lang : 'ch',
					validateOnBlur : false,
					timepicker : false,
					format : 'Y-m-d H:00:00',
					minDate : MIN_DELAY_DAY,
					onChangeDateTime : changeTermDate,
					scrollMonth : false,
					scrollTime : false
				});
				$("#effDate").unbind('mousewheel');
				$('#effDate').val(getDefaultDate(new Date(), 0, 1+Number(MIN_DELAY_DAY)));
				$(".select1").attr('disabled',true);
			}

			var effDate = $('#effDate').val();
			effDate = effDate + "";
			var strdate = effDate;
			strdate = strdate.replace(/-/g, "/");
			var EDate = new Date(strdate);

			if (PPP_UNIT == 'y') {
				EDate.calTermDateByMonthOrYear(effDate, 'Y', MAX_DAYS, INSTANT);
			} else if (PPP_UNIT == 'm') {
				EDate.calTermDateByMonthOrYear(effDate, 'M', MAX_DAYS, INSTANT);
			} else {
				$("#termDate").val(
						getDefaultDate(new Date(), $("#dayCount").val(), 1));
			}
		} else {
			if(INSTANT=='N'){
	            $(".select1").attr('disabled',true);
	        }
			var edate = $("#effDate").val();
			edate = edate + "";
			edate = edate.substring(0, 10);
			var tdate = $("#termDate").val();
			tdate = tdate + "";
			tdate = tdate.substring(0, 10);

			if (PPP_UNIT == 'y') {
				edate = edate.replace(/-/g, "/");
				var dateS = new Date(edate);
				tdate = tdate.replace(/-/g, "/");
				var dateE = new Date(tdate);
				var days = getDateDiff(dateS, dateE);
				$('#dayCount').val(Math.round(days / 365));
			} else if (PPP_UNIT == 'm') {
				$('#dayCount').val(getMonthDiff(edate, tdate));
			}

		}
		$('#globalDMY').html(DMY_DESC);
	}

	//根据起保日期带出终止日期
	function changeTermDate() {
		$('#effDate').css('border', '1px solid #c3c3c3');
		$('#effDate').poshytip('hide');
		var dayCount = $("#dayCount").val();
		var effDate = $("#effDate").val();
		if (effDate.length == 19) {
			if (validateDate(effDate) == false)
				return;
			if (dayCount != '') {
				var realSignFlag = $("input[name='realSignFlag']:checked")
						.val();
				var date = new Date(effDate.replace(/-/g, "/"));
				effDate = effDate + "";
				if (PPP_UNIT == 'y') {
					date.calTermDateByMonthOrYear(effDate, 'Y', dayCount,
							realSignFlag);
				} else if (PPP_UNIT == 'm') {
					date.calTermDateByMonthOrYear(effDate, 'M', dayCount,
							realSignFlag);
				} else {
					$("#termDate").val(getDefaultDate(date, dayCount, 0));
				}
			}
		} else {
			$('#effDate').css('border', '1px solid red');
			$('#effDate').poshytip('update', '起保时间不正确');
			$('#effDate').poshytip('show');
		}
	}

	//获取时间(时间,天数,下一个小时或者下一天)
	function getDefaultDate(date, daySum, next) {
		if (daySum == 365) {
			daySum = processDay(date, daySum);
		}
		var rsf = $("input[name='realSignFlag']:checked").val();
		var year = date.getFullYear();
		var month = (date.getMonth() + 1) < 10 ? ('0' + (date.getMonth() + 1))
				: (date.getMonth() + 1);
		var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
		var hours = date.getHours() < 10 ? '0' + date.getHours() : date
				.getHours();
		if (rsf == 'Y') {
			//即时起保
			date = new Date(year + "/" + month + "/" + day + " " + hours
					+ ":00:00");
			if (daySum == 0) {
				date = new Date(date.getTime() + next * 60 * 60 * 1000);
			} else {
				date = new Date(date.getTime() + next * 60 * 60 * 1000 + daySum
						* 24 * 60 * 60 * 1000);
			}
		} else {
			//非即时起保
			date = new Date(year + "/" + month + "/" + day + " 00:00:00");
			if (daySum == 0) {
				date = new Date(date.getTime() + next * 24 * 60 * 60 * 1000);
			} else {
				date = new Date(date.getTime() + next * 24 * 60 * 60 * 1000
						+ (daySum - 1) * 24 * 60 * 60 * 1000);
			}
		}
		var year1 = date.getFullYear();
		var month1 = (date.getMonth() + 1) < 10 ? ('0' + (date.getMonth() + 1))
				: (date.getMonth() + 1);
		var day1 = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
		var hours1 = date.getHours() < 10 ? '0' + date.getHours() : date
				.getHours();
		if (daySum == 0) {
			return year1 + "-" + month1 + "-" + day1 + " " + hours1 + ":00:00";
		} else {
			if (rsf == 'Y') {
				return year1 + "-" + month1 + "-" + day1 + " " + hours1
						+ ":00:00";
			} else {
				return year1 + "-" + month1 + "-" + day1 + " " + "24:00:00";
			}
		}
	}
	//对特殊的365天进行处理，如果包含瑞年2月，则返回366天
	function processDay(date, daySum) {
		if (date.getMonth() == 1 && date.getDate() != 29) {
			date = new Date(date.getTime() + 1 * 24 * 60 * 60 * 1000);
		}
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		if (month > 2) {
			year = parseInt(year) + 1;
		}
		if ((year % 4 == 0 && year % 100 != 0)
				|| (year % 100 == 0 && year % 400 == 0)) {
			daySum = parseInt(daySum) + 1;
		}
		return daySum;
	}
	//校验投保日期
	function validateDate(effDate) {
		var beginDate = getDefaultDate(new Date(), 0, 1);
		var nowDate = new Date(beginDate.replace(/-/g, "/"));
		var newDate = new Date(effDate.replace(/-/g, "/"));
		var rsf = $("input[name='realSignFlag']:checked").val();
		if (newDate.getTime() < nowDate.getTime()) {
			if (rsf == 'Y') {
				$('#effDate').css('border', '1px solid red');
				$('#effDate').poshytip('update', '即时起保时间为当前时间后整点时间');
				$('#effDate').poshytip('show');
				return false;
			} else {
				$('#effDate').css('border', '1px solid red');
				$('#effDate').poshytip('update', '非即时起保时间至少第二天起');
				$('#effDate').poshytip('show');
				return false;
			}
		}
		if(newDate.getTime()-nowDate.getTime()<MIN_DELAY_DAY*24*60*60*1000){
	        $('#effDate').css('border','1px solid red');
	        $('#effDate').poshytip('update', "最短延保天数不能小于"+MIN_DELAY_DAY+"天");
	        $('#effDate').poshytip('show'); 
	        return false;
	    }
		if (newDate.getTime() - nowDate.getTime() > MAX_DELAY_DAY * 24 * 60
				* 60 * 1000) {
			$('#effDate').css('border', '1px solid red');
			$('#effDate')
					.poshytip('update', "最大延保天数不能超过" + MAX_DELAY_DAY + "天");
			$('#effDate').poshytip('show');
			return false;
		}
	}
	function clearBasicInfoNotice(){
	    $('#dayCount,#clientName1,#certificateCode,#clientBir1,#sexId2').css('border','1px solid #c3c3c3');
	    $('#dayCount,#clientName1,#certificateCode,#clientBir1,#sexId2').poshytip('hide'); 
	}
	
	function hiddedView(id){
	    $("#"+id).poshytip('hide'); 
	}
	function addInsured(){
		idStr=null;
		$("#editInsuredDiv").OpenDiv4(null, 10000);
	}
    //关闭小窗口
    function closeEditInsuredDiv(){
        $("#editInsuredDiv").CloseDiv4();
        $('#clientName2').val('');
        $('#idType').val('');
        $('#idNo').val('');
        $('#clientBir2').val('');
        $('#clientTel2').val('');
        $('#insNationality').val('');
        $('#workIdBbr').val('');
        $("#workNameBbr").val('');
        $(".workLevelBbr").html('');
        $("input[name='sex2']").attr("checked",false);
        $("#clientName2").css('border','1px solid #c3c3c3');
        $('#clientName2').poshytip('hide');
        $("#idType").css('border','1px solid #c3c3c3');
        $('#idType').poshytip('hide');
        $("#idNo").css('border','1px solid #c3c3c3');
        $('#idNo').poshytip('hide');
        $("#clientBir2").css('border','1px solid #c3c3c3');
        $('#clientBir2').poshytip('hide');
        $("#clientTel2").css('border','1px solid #c3c3c3');
        $('#clientTel2').poshytip('hide');
        $("#sexId4").css('border','1px solid #c3c3c3');
        $('#sexId4').poshytip('hide');
    }
    
  //校验出生日期
    function validateIdCode(idNo,cBir,isSex,cBirName,viewFalg){
        var backFalg = true;
        var id="";
        if(viewFalg==1){
            id="certificateCode";
        }else if(viewFalg==2){
            id="idNo";
        }
        if(identityCodeValid(idNo,id)){
            var cB='';
            var sexFalg;
            if(idNo.length==15){
                cB = "19"+idNo.substr(6,2)+"-"+idNo.substr(8,2)+"-"+idNo.substr(10,2);
                if (parseInt(idNo.substr(13, 1)) % 2 == 1) {
                    sexFalg = '1';
                } else {
                    sexFalg = '2';
                } 
            }
            if(idNo.length==18){
                cB = idNo.substr(6,4)+"-"+idNo.substr(10,2)+"-"+idNo.substr(12,2);
                if (parseInt(idNo.substr(16, 1)) % 2 == 1) {
                    sexFalg = '1';
                } else {
                    sexFalg = '2';
                } 
            }
            if(cB!=cBir){
                backFalg = false;
                if(viewFalg==1){
                    $('#clientBir1').css('border','1px solid red');
                    $('#clientBir1').poshytip('update', cBirName+"出生日期与身份证不对应");
                    $('#clientBir1').poshytip('show'); 
                }
                if(viewFalg==2){
                    $('#clientBir2').css('border','1px solid red');
                    $('#clientBir2').poshytip('update', cBirName+"出生日期与身份证不对应");
                    $('#clientBir2').poshytip('show'); 
                }
            }
            if(sexFalg != isSex){
                backFalg = false;
                if(viewFalg==1){
                    $('#sexId2').poshytip('update', cBirName+"性别与身份证不对应");
                    $('#sexId2').poshytip('show'); 
                }
                if(viewFalg==2){
                    $('#sexId4').poshytip('update', cBirName+"性别与身份证不对应");
                    $('#sexId4').poshytip('show'); 
                }
            }
        }else{
            backFalg = false;
        }
        return backFalg;
    }
    //是否闰年
    function isRunYear(date){
        if(date.getMonth()==1 && date.getDate()!=29){
            date = new Date(date.getTime()+1*24*60*60*1000);
        }
        var year = date.getFullYear();
        var month =  date.getMonth()+1;
        if(month>2){
            year = parseInt(year)+1;
        }
        if((year%4==0 && year%100!=0)||(year%100==0 && year%400==0)){
            return true;
        }else{
            return false;
        }
    }
  //关闭提示
    function changeDate(){
        $("#clientBir1").css('border','1px solid #c3c3c3');
        $("#clientBir1").poshytip('hide'); 
        $("#clientBir2").css('border','1px solid #c3c3c3');
        $("#clientBir2").poshytip('hide'); 
    }
    //新增被保人
    function saveInsured(){
        var name = $('#clientName2').val();
        var idtype = $('#idType').val();
        var idtypedesc = $('#idType option:selected').text();
        var no = $('#idNo').val();
        var bir = $('#clientBir2').val();
        var tel = $('#clientTel2').val();
        var sex = $("input[name='sex2']:checked").val();
        var sexdesc = (sex == "" ? "" :$("input[name='sex2'] option:selected").text());
        var insNationality = $('#insNationality').val();
        var workIdBbr=$("#workIdBbr").val();
        var workNameBbr=$("#workNameBbr").val();
        
        if(!checkInsuredPersonInfo()) return;
        //添加之前，遍历数组，判断是否存在重复被保险人（重复条件：姓名+证件类型+证件号码 相同）
         if(facadeAppInsureds.length>0){
            for(var i=0;i<facadeAppInsureds.length;i++){
                if(name==facadeAppInsureds[i].clientName && idtype==facadeAppInsureds[i].idType && no == facadeAppInsureds[i].idNo){
                    if(idStr!=null&&idStr==i){
                        continue;
                    }else{
                        $.message("error","该被保险人"+name+"已存在");
                        return;
                    }
                }
            }
        } 

        var facadeAppInsured = new Object();
        facadeAppInsured.clientName = name;
        facadeAppInsured.idTypeDesc = idtypedesc;
        facadeAppInsured.idType = idtype;
        facadeAppInsured.idNo = no;
        facadeAppInsured.clientTel = tel;
        facadeAppInsured.sex = sex;
        facadeAppInsured.sexdesc = sexdesc;
        facadeAppInsured.clientBir = bir;
        facadeAppInsured.insNationality = insNationality;
        facadeAppInsured.workType = workIdBbr;
        facadeAppInsured.workTypeName = workNameBbr;
        var messageStr;
        if(idStr!=null){
            facadeAppInsureds.splice(idStr,1,facadeAppInsured);
            messageStr="被保险人修改成功";
        }else{
            facadeAppInsureds.splice(facadeAppInsureds.length,1,facadeAppInsured);
            messageStr="被保险人添加成功";
        }
        idStr=null;
        closeEditInsuredDiv();
        loadInsuredInfo(facadeAppInsureds);
        $.message("success",messageStr);
    }
    function checkInsuredPersonInfo(){
    	var backFlag = true;
    	var clientName2 = $("#clientName2").val();
        if(clientName2==''){
            $('#clientName2').css('border','1px solid red');
            $('#clientName2').poshytip('update', '请填写被保人姓名');
            $('#clientName2').poshytip('show'); 
            backFlag = false;
        }
        var idType = $("#idType").val();
        if(idType==''){
            $('#idType').css('border','1px solid red');
            $('#idType').poshytip('update', '请选择被保人证件类型');
            $('#idType').poshytip('show'); 
            backFlag = false;
        }
        var cBir = $("#clientBir2").val();
        if(cBir==''){
            $('#clientBir2').css('border','1px solid red');
            $('#clientBir2').poshytip('update', '请选择被保人出生日期');
            $('#clientBir2').poshytip('show'); 
            backFlag = false;
        }
        var isSex = $("input[name='sex2']:checked").val();
        if(isSex==undefined){
            $("#sexId4").poshytip('update', '请选择被保人性别');
            $("#sexId4").poshytip('show'); 
            backFlag = false;
        }
        var idNo = $("#idNo").val();
        if(idNo==''){
            $('#idNo').css('border','1px solid red');
            $('#idNo').poshytip('update', '请填写被保人证件号码');
            $('#idNo').poshytip('show'); 
            backFlag = false;
        }else if(idType=='01'){
            if(!validateIdCode(idNo,cBir,isSex,'被保人',2)) backFlag = false;
        }
        return backFlag;
    }
    function loadAppFormAndInsured(){
    	var stagNo=$("#stagNo").val();
        $.ajax({
            url : "<%=path%>/activatedCard/queryAppFormInfo",
            type : 'POST',
            async : false,
            dataType:'json',
            data:{'stagNo':stagNo},
            success : function(result) {
                if($.validate(result))return;//系统操作异常提示
                if('error'==result.result){
                	$.message("error",result.message);
                }
                if('fail'==result.result){
                    $.message("error","系统异常，请联系管理员");
                }
                if('success'==result.result){
	                if(result.data!=null){
	                	var data = result.data;
	                	var facadeAppForm=data.facadeAppForm;
	                	facadeAppInsureds=data.facadeAppInsured;
	                	var facadeAppApplicant=data.facadeAppApplicant;
	                	var facadeAppFormExtend=data.facadeAppFormExtend;
	                	var realSignFlag=facadeAppForm.realSignFlag;
	                	$("input[name='realSignFlag']").attr("checked",realSignFlag);
// 	                	$("#trip").val(facadeAppForm.trip);
                        $("#appNo").val(facadeAppForm.app_No);
	                	$("#dayCount").val(facadeAppForm.dayCount);
	                    $("#effDate").val(facadeAppForm.stringEffDate);
	                    $("#termDate").val(facadeAppForm.stringTermDate);
	                    //初始化即时起保引起时间显示
	                    if(facadeAppForm.realSignFlag=='Y'){
	                        $('#effDate').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:true,format:'Y-m-d H:00:00',minDate:'0',minTime:'0',onChangeDateTime:changeTermDate,scrollMonth:false,scrollTime:false});
	                    }else{
	                        $('#effDate').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d H:00:00',minDate:'0',minTime:'0',onChangeDateTime:changeTermDate,scrollMonth:false,scrollTime:false});
	                    }
	                    $("#clientName1").val(facadeAppApplicant.clientName);
	                    $("#certificateType").val(facadeAppApplicant.certificateType);
	                    $("#appNature").val(facadeAppApplicant.appNature);
	                    $("#certificateCode").val(facadeAppApplicant.certificateCode);
	                    $("#clientBir1").val(facadeAppApplicant.clientBir);
	                    
	                    if('1'==facadeAppApplicant.sex){
	                        $("#sexId1").attr("checked",true);
	                    }else if('2'==facadeAppApplicant.sex){
	                        $("#sexId2").attr("checked",true);
	                    }
	                    $("#linkmanTel1").val(facadeAppApplicant.linkmanTel);
	                    $("#email").val(facadeAppApplicant.email);
	                    $("#relWithInsured1").val(facadeAppApplicant.relWithInsured);
	                    $("#appNationality").val(facadeAppApplicant.appNationality);
                        $("#workId").val(facadeAppApplicant.workType);
                        $("#workName").val(facadeAppApplicant.workTypeName);
	                    if(facadeAppFormExtend!=null){
	                    	$("#plateNum").val(facadeAppFormExtend.plateNum);
                            $("#chassisNum").val(facadeAppFormExtend.chassisNum);
                            $("#seatNum").val(facadeAppFormExtend.seatNum);
                            // $("#useNature").val(facadeAppFormExtend.useNature);
                            $("#mainVehicleNature").val(facadeAppFormExtend.mainVehicleNatureStr);
	                    }
	                    loadInsuredInfo(facadeAppInsureds);
	                }
                }
                
            }
        });
    }
    function loadInsuredInfo(facadeAppInsureds){
    	var trHtml;
    	$("#insuredTbody").empty();
        for(var i = 0; i < facadeAppInsureds.length; i++){
            trHtml="<tr><td style='text-align:center'>"+facadeAppInsureds[i].clientName+"</td>"
               +"<td style='text-align:center'>"+facadeAppInsureds[i].idTypeDesc+"</td>"
               +"<td style='text-align:center'>"+facadeAppInsureds[i].idNo+"</td>"
               +"<td style='text-align:center'><a href='javascript:void(0)' onclick=editPerson("+i+")>[编辑]</a><a href='javascript:void(0)' onclick=warnBeforeDelPerson("+i+")>[删除]</a></td></tr>"
            $("#insuredTbody").append(trHtml);
        }
    }
    //编辑被保险人信息
    var idTypeDesc = "";
    function editPerson(id){
    	idStr=id;
    	$('#clientName2').val(facadeAppInsureds[id].clientName);
        $('#idType').val(facadeAppInsureds[id].idType);
        $('#idNo').val(facadeAppInsureds[id].idNo);
        $('#clientTel2').val(facadeAppInsureds[id].clientTel);
        $("input[name='sex2']").attr('checked', false);
        $.each($("input[name='sex2']"), function(i, v) {
            if (v.value === facadeAppInsureds[id].sex) {
                $(v).attr('checked', true)
            }
        });
        $('#clientBir2').val(facadeAppInsureds[id].clientBir);
        $('#insNationality').val(facadeAppInsureds[id].insNationality);
        $("#clientTel2").val(facadeAppInsureds[id].clientTel);
        $("#workIdBbr").val(facadeAppInsureds[id].workType);
        $("#workNameBbr").val(facadeAppInsureds[id].workTypeName);
        
        $('#editInsuredDiv').OpenDiv4(null, 10000);
    }
    function warnBeforeDelPerson(id){
        $.dialog({
            type: "warn",
            content: "确定要删除该被保险人吗？",
            onOk: function() {
                deleteInsuredPerson(id);
            }
        });
    }
    //删除被保险人
    function deleteInsuredPerson(id){
        $.openLoading_jhk();
        facadeAppInsureds.splice(id, 1);
        loadInsuredInfo(facadeAppInsureds);
        $.closeLoading();
        $.message("success","被保险人删除成功");
    }
    //暂存接口
    function tempSave(){
        var appNo=$("#appNo").val();
        var stagNo=$("#stagNo").val();
        if(false==validateData()) return false;
        var baseInfo=getBaseInfo();
        if(baseInfo==false)return false;
        var appLicant=getAppLicant();
        if(appLicant==false)return false;
        var appNo = $("#appNo").val();
        var stagNo = $("#stagNo").val();
        $.openLoading_jhk();
        $.ajax({
            url : "activatedCard/group/saveTemporary",
            type : 'POST',
            async : true,
            dataType:'json',
            data:{"baseInfo":JSON.stringify(baseInfo),
                  "appLicant":JSON.stringify(appLicant),
                  "insureds":JSON.stringify(facadeAppInsureds),
                  "appNoJm":appNo,
                  "stagNoJm":stagNo
                },
            success : function(result){
                $.closeLoading();
                if("fail"==result.result){
                    $.message("error", "系统错误,请联系管理员");
                    return true;
                }
                if("success"==result.result){
                    $("#stagNo").val(result.data[0]);
                    $("#appNo").val(result.data[1]);
                    $.message("success",result.message)
                }else{
                    if(result.data != null){
                        $("#stagNo").val(result.data[0]);
                        $("#appNo").val(result.data[1]);
                    }
                    $.message("error", result.message);
                }
            }
        }); 
    }
    //投保预览接口
    function previewSubmit(){
        var appNo=$("#appNo").val();
        var stagNo=$("#stagNo").val();
        if(false==validateData()) return false;
        var baseInfo=getBaseInfo();
        if(baseInfo==false)return false;
        var appLicant=getAppLicant();
        if(appLicant==false)return false;
        var appNo = $("#appNo").val();
        var stagNo = $("#stagNo").val();
        $.openLoading_jhk();
        $.ajax({
            url : "activatedCard/group/saveTemporary",
            type : 'POST',
            async : true,
            dataType:'json',
            data:{"baseInfo":JSON.stringify(baseInfo),
                  "appLicant":JSON.stringify(appLicant),
                  "insureds":JSON.stringify(facadeAppInsureds),
                  "appNoJm":appNo,
                  "stagNoJm":stagNo
                },
            success : function(result){
                if("fail"==result.result){
                    $.closeLoading();
                    $.message("error", "系统错误,请联系管理员");
                    return true;
                }
                if("success"==result.result){
                    $("#stagNo").val(result.data[0]);
                    $("#appNo").val(result.data[1]);
                    if(result.data[2]!=null){
                   		$("#warnInfo").val(result.data[2]);
                    }
                    window.location.href='<%=path%>/activatedCard/group/previewGroup';
                }else{
                    $.closeLoading();
                    if(result.data != null){
                        $("#stagNo").val(result.data[0]);
                        $("#appNo").val(result.data[1]);
                    }
                    $.message("error", result.message);
                }
            }
        });
    }
    //数据校验
    function validateData(){
    	if(riskMainType!='2'){
            //被保险人数校验
            var count = $('#insuredTable tbody tr:eq(0) td').length;
            if(count<1){
                $.message("error","请先添加被保险人");
                backFlag = false;
                return backFlag;
            }
    	}
        var backFlag = true;
        var realSignFlag = $("input[name='realSignFlag']:checked").val();
        if(realSignFlag==undefined){
            $.message("error","请选择是否即时起保");
            backFlag = false;
        }
        if(realSignFlag=='Y' && INSTANT=='N'){
            $.message("error","是否即时起保请选择否");
            backFlag = false;
        }
//         var anesthType = $("#anesthType").val();
//         if(global_SPECIAL_INFO == 1){
//             if(anesthType == ''){
//                 $('#anesthType').css('border','1px solid red');
//                 $('#anesthType').poshytip('update', '请选择麻醉类型');
//                 $('#anesthType').poshytip('show'); 
//                 backFlag = false; 
//             }           
//         }
//         var studentType = $("#studentType").val();
//         var schoolType = $("#schoolType").val();
//         if(global_SPECIAL_INFO == 3){
//             if(studentType == ''){
//                 $('#studentType').css('border','1px solid red');
//                 $('#studentType').poshytip('update', '请选择学生类别');
//                 $('#studentType').poshytip('show'); 
//                 backFlag = false; 
//             }   
//             if(schoolType == ''){
//                 $('#schoolType').css('border','1px solid red');
//                 $('#schoolType').poshytip('update', '请选择学校类别');
//                 $('#schoolType').poshytip('show'); 
//                 backFlag = false; 
//             }
//         }
//         var trip = $("#trip").val();
//         if(global_SPECIAL_INFO == 2){
//             if(trip == ''){
//                 $('#trip').css('border','1px solid red');
//                 $('#trip').poshytip('update', '请填写行程/航班');
//                 $('#trip').poshytip('show'); 
//                 backFlag = false; 
//             }
//         }
        var dayCount = $("#dayCount").val();
        if(dayCount==''){
            $('#dayCount').css('border','1px solid red');
            $('#dayCount').poshytip('update', '请填写'+DMY_DESC);
            $('#dayCount').poshytip('show'); 
            backFlag = false;
        }
        if(isNaN(dayCount)){
            $('#dayCount').css('border','1px solid red');
            $('#dayCount').poshytip('update', DMY_DESC+'应为整数');
            $('#dayCount').poshytip('show'); 
            backFlag = false; 
        }
        if(dayCount-MIN_DAYS<0){
            $('#dayCount').css('border','1px solid red');
            $('#dayCount').poshytip('update', DMY_DESC+"最小为"+MIN_DAYS);
            $('#dayCount').poshytip('show');
            backFlag = false;
        }
        var MAXDAY1 = MAX_DAYS;
        if(MAX_DAYS==365) MAXDAY1=366;
        if(dayCount-MAXDAY1>0){
            $('#dayCount').css('border','1px solid red');
            $('#dayCount').poshytip('update', DMY_DESC+"最大为"+MAX_DAYS);
            $('#dayCount').poshytip('show');
            backFlag = false;
        }

        var effDate = $("#effDate").val();
        if(effDate==''){
            $('#effDate').css('border','1px solid red');
            $('#effDate').poshytip('update', '请选择起保日期');
            $('#effDate').poshytip('show');
            backFlag = false;
        }
        
        if(validateDate(effDate)==false) return false;
        
        var dateCur = new Date(effDate.replace(/-/g, "/"));
        if(dayCount==366 && !isRunYear(dateCur)){
            $('#dayCount').css('border','1px solid red');
            $('#dayCount').poshytip('update', "平年保险天数最大为365天");
            $('#dayCount').poshytip('show');
            backFlag = false;
        }       
        
        var clientName1 = $("#clientName1").val();
        if(clientName1==''){
            $('#clientName1').css('border','1px solid red');
            $('#clientName1').poshytip('update', '请填写投保人姓名');
            $('#clientName1').poshytip('show'); 
            backFlag = false;
        }
        var certificateType = $("#certificateType").val();
        if(certificateType==''){
            $('#certificateType').css('border','1px solid red');
            $('#certificateType').poshytip('update', '请选择投保人证件类型');
            $('#certificateType').poshytip('show'); 
            backFlag = false;
        }
        var certificateCode = $("#certificateCode").val();
        if(certificateCode==''){
            $('#certificateCode').css('border','1px solid red');
            $('#certificateCode').poshytip('update', '请填写投保人证件号码');
            $('#certificateCode').poshytip('show'); 
            backFlag = false;
        }else if(certificateType=='01'){
            var isSex = $("input[name='sex1']:checked").val();
            var cBir = $("#clientBir1").val();
            if(!validateIdCode(certificateCode,cBir,isSex,'投保人',1)){
                backFlag = false;
            } 
        }
        var linkmanTel1 = $("#linkmanTel1").val();
        if(linkmanTel1==''){
            $('#linkmanTel1').css('border','1px solid red');
            $('#linkmanTel1').poshytip('update', '请选择投保人手机号码');
            $('#linkmanTel1').poshytip('show'); 
            backFlag = false;
        }
        var email = $("#email").val();
        if(email==''){
            $('#email').css('border','1px solid red');
            $('#email').poshytip('update', '请选择投保人邮箱');
            $('#email').poshytip('show'); 
            backFlag = false;
        }else{
            var emailReg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/g;
            if(!emailReg.test(email)){
                $('#email').css('border','1px solid red');
                $('#email').poshytip('update', '电子邮箱格式错误');
                $('#email').poshytip('show'); 
                backFlag = false;
            }
        }
        if(riskMainType != '2'){
	        var relWithInsured1 = $("#relWithInsured1").val();
	        if(relWithInsured1==''){
	            $('#relWithInsured1').css('border','1px solid red');
	            $('#relWithInsured1').poshytip('update', '请选择投保人与被保人关系');
	            $('#relWithInsured1').poshytip('show'); 
	            backFlag = false;
	        } else if (relWithInsured1=='01') {
	            $('#relWithInsured1').css('border','1px solid red');
	            $('#relWithInsured1').poshytip('update', '投保人与被保人关系不可以选本人');
	            $('#relWithInsured1').poshytip('show'); 
	            backFlag = false;
	        }
        }
        var cBir = $("#clientBir1").val();
        if(cBir==''){
            $('#clientBir1').css('border','1px solid red');
            $('#clientBir1').poshytip('update', '请选择投保人出生日期');
            $('#clientBir1').poshytip('show'); 
            backFlag = false;
        }
        var isSex = $("input[name='sex1']:checked").val();
        if(isSex==undefined){
            $("#sexId2").poshytip('update', '请选择投保人性别');
            $("#sexId2").poshytip('show'); 
            backFlag = false;
        }
        if(riskMainType == '2'){
            var plateNum = $("#plateNum").val();
            if(plateNum == ''){
                $('#plateNum').css('border','1px solid red');
                $('#plateNum').poshytip('update', '请填写车牌号');
                $('#plateNum').poshytip('show'); 
                backFlag = false; 
            }
            var chassisNum = $("#chassisNum").val();
            if(chassisNum==''){
                $('#chassisNum').css('border','1px solid red');
                $('#chassisNum').poshytip('update', '请填写车架号');
                $('#chassisNum').poshytip('show'); 
                backFlag = false; 
            }
            var seatNum = $("#seatNum").val();
            if(seatNum == ''){
                $('#seatNum').css('border','1px solid red');
                $('#seatNum').poshytip('update', '请填写投保座位数');
                $('#seatNum').poshytip('show'); 
                backFlag = false; 
            }
            /*var useNature = $("#useNature").val();
            if(useNature == ''){
                $('#useNature').css('border','1px solid red');
                $('#useNature').poshytip('update', '请选择车辆使用性质');
                $('#useNature').poshytip('show'); 
                backFlag = false; 
            }*/
            var mainVehicleNature = $("#mainVehicleNature").val();
            if(mainVehicleNature == ''){
                $('#mainVehicleNature').css('border','1px solid red');
                $('#mainVehicleNature').poshytip('update', '请选择车辆性质');
                $('#mainVehicleNature').poshytip('show'); 
                backFlag = false; 
            }
        }
        return backFlag;
    }
    function getBaseInfo(){
        var pmb={};
        pmb.insuPlanNo=$("#planNo").val();
        pmb.insuPlanNoDscp=$("#planName").val();
        pmb.realSignFlag=$("input:radio[name='realSignFlag']:checked").val();
        pmb.dayCount=$("#dayCount").val();
        pmb.unirPp="1";
//         pmb.trip=$("#trip").val();
        pmb.effDate=$("#effDate").val();
        pmb.termDate=$("#termDate").val();
        pmb.totPremamt=$("#totPremamt").val();
        pmb.relWithInsured=$("#relWithInsured1").val();
        pmb.anesthType=$("#anesthType").val();
        pmb.partnerNo=$("#partnerNo").val();
        //驾乘险信息
        if(riskMainType=='2'){
            pmb.plateNum=$("#plateNum").val();
            pmb.chassisNum=$("#chassisNum").val();
            pmb.seatNum=$("#seatNum").val();
            // pmb.useNature=$("#useNature").val();
            pmb.mainVehicleNature=$("#mainVehicleNature").val();
        }
        return pmb;
    }
    function getAppLicant(){//投保人信息
        var licant={};
        licant.clientName=$("#clientName1").val();
        licant.clientBir=$("#clientBir1").val();
        licant.certificateType=$("#certificateType").val();
        licant.certificateCode=$("#certificateCode").val();
        licant.sex=$("input[name='sex1']:checked").val();
        licant.linkmanTel=$("#linkmanTel1").val();
        licant.email=$("#email").val();
        licant.appNationality=$("#appNationality").val();
        licant.relWithInsured=$("#relWithInsured1").val();
        licant.workType=$("#workId").val();
        licant.appNature=$("#appNature").val();
        return licant;
    }
    function openWorkDiv(str) {
        
        flag=str;
        menuTreeInit();// 职业类别树初始化
        window.setTimeout(function () {
            // document.getElementById('workDiv').style.display = 'block';
            $('#workDiv').OpenDiv4('workBigDiv', '20000')
        },1000)
    }
    //职业列表初始化 start 
    function menuTreeInit() {
        // ztree 配置
        var setting = {
            view: {
                dblClickExpand: false
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                beforeClick: beforeClick,
                onDblClick: onDblClick
            },
            async: {
                enable: true,
                url:"activatedCard/queryWorkTree",// 查询下级
                autoParam:["id"],
                dataFilter: filter,
                dataType: 'json'
            }
        }
        // 展示职业树
        $.fn.zTree.init($("#ztree"), setting);
    }
    function beforeClick(treeId, treeNode) {
        var check = (treeNode && !treeNode.isParent);
        if (!check) $.message("error", "只能选择三级职业类型！");
        return check;
    }

    function onDblClick(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj("ztree")
        var node = zTree.getSelectedNodes()
        if (node.length!=0) {
            if(flag=='0'){
                $('#workId').val(node[0].id)
                $('#workName').val(node[0].name)
                $('.workLevel').html(node[0].workLevel)
            }else if(flag=='1'){
                $('#workIdBbr').val(node[0].id)
                $('#workNameBbr').val(node[0].name)
                $('.workLevelBbr').html(node[0].workLevel)
            }
            closeCurrentDIV4('workDiv', 'workBigDiv');
        }else{
            $.message("error", "请选择职业类型！");
        }
    }
    //选定职业类型，点击确定
    function selectWork() {
        var treeObj = $.fn.zTree.getZTreeObj("ztree");
        var node = treeObj.getSelectedNodes();
        if(node.length!=0){
            if(flag=='0'){
                $('#workId').val(node[0].id)
                $('#workName').val(node[0].name)
                $('.workLevel').html(node[0].workLevel)
            }else if(flag=='1'){
                $('#workIdBbr').val(node[0].id)
                $('#workNameBbr').val(node[0].name)
                $('.workLevelBbr').html(node[0].workLevel)
            }
            closeCurrentDIV4('workDiv', 'workBigDiv');
        }else{
            $.message("error", "请选择职业类型！");
        }
    }
    function filter(treeId, parentNode, childNodes) {
        if (!childNodes) {
            return null;
        };
        var newChildNodes = $.map(childNodes, function (v, i) {
            var item = {
                'id': v.occCode,
                'pid': v.parentCode,
                'name': v.occName,
                'isParent': v.isParent,
                'workLevel':v.occLevelDesc
            }
            return item
        });
        return newChildNodes;
    }
    function closeCurrentDIV4(obj, ele){
        $("#"+obj).CloseDiv4(ele);
    }
</script>
</head>
<body>
	<input type="hidden" name="stagNo" id="stagNo" value="${stagNo}" />
	<input type="hidden" name="planNo" id="planNo"
		value="${prodInfo.planNo}" />
	<input type="hidden" name="planName" id="planName"
		value="${prodInfo.planName}" />
	<input type="hidden" name="partnerNo" id="partnerNo"
		value="${prodInfo.partnerNo}" />
	<input type="hidden" name="appNo" id="appNo" />
	<input type="hidden" name="MAX_DAYS" id="MAX_DAYS"
		value="${prodInfo.maxDays}" />
	<input type="hidden" name="MIN_DAYS" id="MIN_DAYS"
		value="${prodInfo.minDays}" />
	<input type="hidden" name="UNIR_PP" id="UNIR_PP"
		value="${prodInfo.unirPp}" />
	<input type="hidden" name="MAX_DELAY_DAY" id="MAX_DELAY_DAY"
		value="${prodInfo.maxDelayDay}" />
	<input type="hidden" name="MIN_DELAY_DAY" id="MIN_DELAY_DAY" value ="${prodInfo.minDelayDay}"/>
	<input type="hidden" name="INSTANT" id="INSTANT"
		value="${prodInfo.instant}" />
	<input type="hidden" name="PPP_UNIT" id="PPP_UNIT"
		value="${prodInfo.pppUnit}" />
	<input type="hidden" name="global_SPECIAL_INFO"
		id="global_SPECIAL_INFO" value="${prodInfo.specialInfo}" />
	<input type="hidden" name="riskMainType" id="riskMainType" value ="${prodInfo.riskMainType}"/>
	<input type="hidden" name="pricelessType" id="pricelessType"
		value="${prodInfo.cardInfo.pricelessType}" />
	<input type="hidden" name="isSeeMoney" id="isSeeMoney"
		value="${prodInfo.isSeeMoney}" />
	<input type="hidden" name="editFlag" id="editFlag" value="${editFlag}" />
	<div class="current">
		<table class="current_table_1">
			<tbody>
				<tr class="f2">
					<td><img src="./images/current_1.jpg"></td>
					<td class="current_table_1_td"><img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
						<span style="color: #136bab;">激活卡管理 <span
							style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>激活卡激活
							<span
							style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>团单激活
					</span></td>
					<td><img src="./images/current_3.jpg"></td>
				</tr>
			</tbody>
		</table>
	</div>
	<div class="setp"><jsp:include page="../include/stepScroll.jsp" /></div>
	<div>
		<table class="table_05">
			<tbody>
				<tr>
					<td colspan="4"
						style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">卡单信息</td>
				</tr>
				<tr>
					<th width="25%">卡名称：</th>
					<td width="28%"><input name="name" id="name"
						value="${prodInfo.cardInfo.name}" type="text" readonly="readonly"
						style="background-color: #ccc;" class="input_text"></td>
					<th width="22%">卡号：</th>
					<td width="20%"><input id="cardNo" type="text"
						value="${prodInfo.cardInfo.cardNo}" readonly="readonly"
						style="background-color: #ccc;" class="input_text"></td>
				</tr>
				<tr>
				</tr>
				<tr>
					<th>保费(元)：</th>
					<td colspan='3'><input id="totPremamt" type="text"
						value="${prodInfo.cardInfo.totPremamt}" readonly="readonly"
						style="background-color: #ccc;" class="input_text"></td>
				</tr>
				<tr>
					<td colspan="4"
						style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">基本信息
					</td>
				</tr>
				<tr>
					<th>投保方案：</th>
					<td><input name="planName" id="planName" type="text"
						value="${prodInfo.planName}" readonly="readonly"
						style="background-color: #ccc;" class="input_text"></td>
					<th>即时起保：</th>
					<td><input type="radio" style="cursor: pointer;"
						name="realSignFlag" class="realSignFlag select1" value="Y" />是 <input
						type="radio" style="cursor: pointer;"
						name="realSignFlag" class="realSignFlag select2" value="N" />否</td>
				</tr>
<!-- 				<tr style="display: none;" id="tripId"> -->
<!-- 					<th>行程/航班：</th> -->
<!-- 					<td><input name="trip" id="trip" type="text" -->
<!-- 						class="input_text"> <span -->
<!-- 						class="red">*</span></td> -->
<!-- 				</tr> -->
				<tr>
					<th id="globalDMY">保险天数：</th>
					<td><input name="dayCount" maxlength="7" id="dayCount"
						class="input_text"> <span
						class="red">*</span></td>
					<th>起保日期：</th>
					<td><input name="effDate" id="effDate" readonly="readonly"
						class="input_text"> <span class="red">*</span>
					</td>
				</tr>
				<tr>
					<th>终保日期：</th>
					<td colspan='3'><input name="termDate" id="termDate"
						readonly="readonly" class="input_text">
					</td>
				</tr>
				<tr name="drivingInfo">
                    <th>车牌号：</th>
                   <td>
                       <input class="input_text notNullClass" name="plateNum" maxlength="50" id="plateNum"/>
                       <span class="red">*</span>
                   </td>
                    <th>车架号：</th>
                   <td>
                       <input class="input_text notNullClass" name="chassisNum" maxlength="50" id="chassisNum"/>
                       <span class="red">*</span>
                   </td>
                </tr>
                <tr name="drivingInfo">
                    <th>投保座位数：</th>
                   <td>
                       <input class="input_text notNullClass" name="seatNum" maxlength="10" id="seatNum"/>
                       <span class="red">*</span>
                   </td>
                    <%--<th>车辆使用性质：</th>
                   <td>
                       <select name="useNature" id="useNature"
                        style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
                            <c:forEach var="n" items="${useNatureList}">
                                <option value="${n.code}">${n.codeName}</option>
                            </c:forEach>
                       </select>
                   </td>--%>
                    <th>车辆性质：</th>
                    <td>
                        <select name="mainVehicleNature" id="mainVehicleNature"
                                style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
                            <c:forEach var="n" items="${mainVehicleNatureList}">
                                <option value="${n.code}">${n.codeName}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
				<tr>
					<td colspan="4"
						style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">投保人信息
					</td>
				</tr>
				<tr>
					<th>投保人姓名：</th>
					<td><input class="input_text notNullClass" name="clientName1"
						maxlength="35" id="clientName1" /> <span class="red">*</span>
					</td>
					<th>投保人性质：</th>
                   <td>
                       <select name="appNature" id="appNature" onchange="changeTbrIdType()" style="width:250px;display:inline-block;border:1px solid #c3c3c3;">
                          	<option value="1">自然人</option>
							<option value="5">企业</option>
							<option value="7">其他社会团体</option>
							<option value="9">军队</option>
							<option value="10">外企</option>
							<option value="11">村委会</option>
                       </select>
                       <span class="red">*</span>
				</tr>
				<tr>
					<th>证件类型：</th>
					<td><select name="certificateType" id="certificateType"
						style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
							<c:forEach var="idType" items="${idTypeList}">
								<option value="${idType.code}">${idType.codeName}</option>
							</c:forEach>
					</select> <span class="red">*</span></td>
					<th>证件号码：</th>
					<td><input class="input_text notNullClass" name="certificateCode"
						maxlength="20" id="certificateCode" />
						<span class="red">*</span>
				    </td>
				</tr>
				<tr>
                    <th>出生日期：</th>
                    <td><input class="input_text notNullClass" name="clientBir1" readonly
                        id="clientBir1" /> <span class="red" name="redInfo">*</span></td>
					<th>性别：</th>
					<td><input type="radio" style="cursor: pointer;"
						name="sex1" id="sexId1" onclick="hiddedView('sexId2')" value="1" />男
						<input type="radio" style="cursor: pointer;"
						name="sex1" id="sexId2" onclick="hiddedView('sexId2')" value="2" />女
						<span class="red" name="redInfo">*</span></td>
				</tr>
				<tr>
                    <th>手机号码：</th>
                    <td>
                        <input class="input_text notNullClass" name="linkmanTel1" id="linkmanTel1" />
                        <span class="red">*</span>
                    </td>
					<th>电子邮箱：</th>
					<td>
					    <input class="input_text notNullClass" name="email" id="email" />
					    <span class="red">*</span>
					</td>
				</tr>
                <tr>
                    <th>投保人国籍：</th>
                    <td><select name="appNationality" id="appNationality"
                        style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
                            <c:forEach var="n" items="${nationalityList}">
                                <option value="${n.code}">${n.codeName}</option>
                            </c:forEach>
                    </select> <span class="red" name="redInfo">*</span></td>
                    <th>职业类别：</th>
                    <td colspan='3'><input id="workName" type="text" class="input_text" style="width:170px" disabled value="${facadeAppApplicant.workTypeName}">
                        <input type="button" class="input_button_1" id="" value="选择" onClick="openWorkDiv('0')" />
                        <input id="workId" type="hidden"/>
                        <span class="workLevel red" style="margin-left:20px;"></span>
                    </td>
                </tr>
				<tr id='commonInsure'>
					<th>与被保人关系：</th>
					<td><select name="relWithInsured1" id="relWithInsured1"
						style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
							<option value="">-----请选择-----</option>
							<c:forEach var="rela" items="${relaList}">
								<option value="${rela.code}">${rela.codeName}</option>
							</c:forEach>
					</select> <span class="red">*</span></td>
				</tr>
			</tbody>
		</table>
	</div>	
    <div id="drivingShow" style="display:none">
     <table class="table_05 ">
        <tr>
            <td colspan="4"
                style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">被保人信息
            </td>
        </tr>
        <tr>
          <td colspan='4'>发生保险责任范围内的交通事故时驾驶或乘坐本保险合同载明的车辆内的人员</td>
        </tr>
    </table>
    </div>
	<div class="appInsuredClass">
		<table class="table_05 ">
			<tr>
				<td colspan="4"
					style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">被保人列表
					&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="input_button_2" onclick="addInsured()"
					value="添加" />
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<table id="insuredTable" class="table_05" style="width: 80%;">
						<thead>
							<tr
								style="font-size: 12px; font-weight: bold; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">
								<th style="text-align: center">姓名</th>
								<th style="text-align: center">证件类型</th>
								<th style="text-align: center">证件号</th>
								<th style="text-align: center">操作</th>
							</tr>
						</thead>
						<tbody id="insuredTbody">
						<tr></tr>
						</tbody>
					</table>
				</td>
			</tr>
		</table>
	</div>
	<div id="editInsuredDiv"
		style="display: none; overflow-y: auto; width: 60%">
		<div class="table_title_div">
			<table class="table_title" style='width: 100%; height: 20px;'>
				<tr>
					<td width="10%"></td>
					<td width="80%" id="interfaceName"></td>
					<td width="10%" align="right"><img
						src="/manager/images/closedown.gif" alt="关闭"
						onclick="closeEditInsuredDiv()" /></td>
				</tr>
			</table>
		</div>
		<!-- 修改id 名 -->
		<h1 style="font-weight: bold; text-align: center; color: #3876bf;">新增/编辑被保险人</h1>
		<table class="table_05" id="addtempletTable" style="width:90%">
			<tr>
				<th style="width:40%">被保人姓名：</th>
				<td style="width:60%"><input class="input_text notNullClass"
					name="clientName2" id="clientName2" /> <span class="red">*</span>
				</td>
			</tr>
			<tr>
				<th>证件类型：</th>
				<td><select name="idType" id="idType"
					style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
						<c:forEach var="idType1" items="${idNature}">
							<option value="${idType1.code}">${idType1.codeName}</option>
						</c:forEach>
				</select> <span class="red">*</span></td>
			</tr>
			<tr>
				<th>证件号码：</th>
				<td><input class="input_text notNullClass" name="idNo" id="idNo" /> <span class="red">*</span></td>
			</tr>
			<tr>
				<th>出生日期：</th>
				<td><input readonly class="input_text notNullClass" type="text"
					name="clientBir2" id="clientBir2" /> <span class="red">*</span>
				</td>
			</tr>
			<tr>
				<th>性别：</th>
				<td><input type="radio" style="cursor: pointer;"
					name="sex2" id="sexId3" onclick="hiddedView('sexId4')" value="1" />男
					<input type="radio" style="cursor: pointer;"
					name="sex2" id="sexId4" onclick="hiddedView('sexId4')" value="2" />女
					<span class="red">*</span></td>
			</tr>
			<tr>
				<th>手机号码：</th>
				<td><input class="input_text" name="clientTel2"
					id="clientTel2" /></td>
			</tr>
			<tr>
				<th>被保人国籍：</th>
				<td><select name="insNationality"
					id="insNationality"
					style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
						<c:forEach var="n" items="${nationalityList}">
							<option value="${n.code}">${n.codeName}</option>
						</c:forEach>
				</select> <span class="red">*</span></td>
			</tr>
			<tr>
            <th>职业类别：</th>
	            <td><input id="workNameBbr" type="text" class="input_text" disabled>
	                <input type="button" class="input_button_1" id="" value="选择" onClick="openWorkDiv('1')" />
	                <input id="workIdBbr" type="hidden"/>
	                <span class="workLevelBbr red" style="margin-left:4px;"></span>
	            </td>
            </tr>
		</table>
		<div align="center">
			<input class="input_button_3" name="" type="button"
				onclick="saveInsured()" value="确定">&nbsp;&nbsp; <input
				class="input_button_3" name="" type="button"
				onclick="closeEditInsuredDiv()" value="取消">
		</div>
	</div>
	<br>
	<br>
	<div align="center">
		<input class="input_button_2" name="" type="button"
			onclick="tempSave()" value="保  存">&nbsp;&nbsp; <input
			class="input_button_2" name="" type="button"
			onclick="previewSubmit()" value="下一步">
	</div>
	<br>
    
    <!--    添加模板 DIV 默认隐藏-->
    <div id="workDiv" style="display: none; width: 500px;position:absolute;left:20%;top:20%;z-index:10010;background:white;">
        <div class="table_title_div">
            <table class="table_title" style='width: 100%; height: 20px;'>
                <tr>
                    <td width="10%"></td>
                    <td width="80%" id="interfaceName"></td>
                    <td width="10%" align="right"><img
                        src="./images/closedown.gif" alt="关闭"
                        onclick="closeCurrentDIV4('workDiv', 'workBigDiv')" /></td>
                </tr>
            </table>
        </div>
        <div class="table_title_body scroll_body">
            <ul class="ztree" id="ztree">
            </ul>
        </div>
        <div align="center">
            <input class="input_button_3" type="button" onclick="selectWork()" value="确定">&nbsp;&nbsp; 
            <input class="input_button_3" type="button" onclick="closeCurrentDIV4('workDiv', 'workBigDiv')" value="取消">
        </div>
    </div>
</body>
</html>